<script setup>
import { nextTick, reactive, ref } from "vue";
import { useRouter } from "vue-router";
import { Message } from "@arco-design/web-vue";
import scoreTemplateApi from "@/api/scoreTemplateApi";
import roleApi from "@/api/roleApi";
import schoolApi from "@/api/schoolApi";
import projectApi from "@/api/projectApi";
import constants from "@/utils/constants";
import Upload from "@/components/Upload.vue";

const router = useRouter();

const submitForm = ref();
const searchForm = ref();
const prjSearchForm = ref();
const standardSearchForm = ref();

const currentTemplateId = ref(null);

const searchModel = reactive({});
const visible = ref(false);
let showTempDialog = ref(false);
const loading = ref(false);

let submitData = ref({});
const roleList = ref([]);
const schoolList = ref([]);

let pagination = reactive({
  total: 0,
  current: 1,
  pageSize: 15,
  showPageSize: true,
  pageSizeOptions: [15, 25, 30, 50],
  showTotal: true,
  pageChange: (current) => {
    pagination.current = current;
    search();
  },
  pageSizeChange(size) {
    pagination.pageSize = size;
    search();
  },
});

const columns = [
  {
    title: "ID",
    dataIndex: "id",
    width: 100,
  },
  {
    title: "模板名称",
    dataIndex: "name",
    width: 200,
  },
  {
    title: "类型",
    slotName: "type",
    width: 100,
  },
  {
    title: "创建时间",
    dataIndex: "createTime",
    width: 180,
  },
  {
    title: "操作",
    slotName: "action",
    fixed: "right",
    width: 200,
  },
];
const data = ref([]);

const showAddDialog = () => {
  visible.value = true;
  submitForm.value.resetFields();
  submitData.value = {};
};

const editRecord = (record) => {
  scoreTemplateApi.queryEditPermission({
    id: record.id
  }).then(res => {
    if (res) {
      visible.value = true;
      nextTick(() => {
        submitForm.value.resetFields();
        submitData.value = Object.assign({}, record);
      });
    }
  })
};

const deleteRecord = (record) => {
  scoreTemplateApi.queryEditPermission({
    id: record.id
  }).then(res => {
    if (res) {
      scoreTemplateApi
        .delete({
          id: record.id,
        })
        .then((res) => {
          search();
        });
    }
  });
};

const handleSubmitSuccess = (values, e) => {
  scoreTemplateApi.save(values).then((res) => {
    visible.value = false;
    Message.success("保存成功");
    search();
  });
};

const search = (current = 1, size = 15) => {
  var params = {
    pageNo: pagination.current,
    pageSize: pagination.pageSize,
    queryParam: Object.assign({}, searchModel),
  };
  loading.value = true;
  scoreTemplateApi.queryPage(params).then((res) => {
    data.value = res.records;
    pagination.total = res.total;
    loading.value = false;
  });
};

const refresh = () => {
  search();
};

const showManagerDialog = (record) => {
  scoreTemplateApi.queryEditPermission({
    id: record.id
  }).then(res => {
    if (res) {
      showTempDialog.value = true;
      currentTemplateId.value = record.id;
      searchPrjModel.templateId = record.id;
      standardSearchModel.templateId = record.id;
      totalStandardSearchModel.templateId = record.id;
      prjModel.value.templateId = record.id;
      submitStandardData.value.templateId = record.id;
      searchPrj();
      standardSearch();
      totalStandardSearch();
    }
  });
}

const queryRoleList = () => {
  roleApi.queryList().then(res => {
    roleList.value = res;
  })
}

const querySchoolList = () => {
  schoolApi.querySchoolList().then(res => {
    schoolList.value = res;
  })
}

const prjLoading = ref(false);
const prjPagination = reactive({
  total: 0,
  current: 1,
  pageSize: 15,
  showPageSize: true,
  pageSizeOptions: [15, 25, 30, 50],
  showTotal: true,
  pageChange: (current) => {
    prjPagination.current = current;
    searchPrj();
  },
  pageSizeChange(size) {
    prjPagination.pageSize = size;
    searchPrj();
  },
});

const prjColumns = [
  {
    title: "项目名称",
    dataIndex: "projectName",
    width: 150
  },

  {
    title: "成绩下限",
    dataIndex: "minValue",
  },
  {
    title: "成绩上限",
    dataIndex: "maxValue",
  },
  {
    title: "小数点进位",
    dataIndex: "radixLength",
  },
  {
    title: "进位类型",
    dataIndex: "radixType",
  },
  {
    title: "年级",
    dataIndex: "gradeName",
  },
  {
    title: "项目权重",
    dataIndex: "prjWeight",
  },
  {
    title: "项目类型",
    dataIndex: "prjType",
  },
  {
    title: "项目单位",
    dataIndex: "prjUnit",
  },
  {
    title: "操作",
    slotName: "action",
    fixed: "right",
    width: 150,
  },
];
const prjData = ref([]);
const showAddPrjDialog = ref(false);
const uploadPrjData = ref({});

const showAddPrj = () => {
  showAddPrjDialog.value = true;
  nextTick(() => {
    prjForm.value.resetFields();
    prjModel.value.templateId = currentTemplateId.value;
  });
}

const prjModel = ref({})
const prjForm = ref();

const editPrjRecord = (record) => {
  showAddPrjDialog.value = true;
  nextTick(() => {
    prjForm.value.resetFields();
    prjModel.value = Object.assign({}, record);
  });
};

const deletePrjRecord = (record) => {
  projectApi
    .delete({
      id: record.id,
    })
    .then((res) => {
      searchPrj();
    });
};

const handleProjectSubmitSuccess = (values, e) => {
  values.templateId = currentTemplateId.value;
  projectApi.save(values).then((res) => {
    showAddPrjDialog.value = false;
    Message.success("保存成功");
    searchPrj();
  });
};

const searchPrjModel = reactive({});
const totalStandardSearchModel = reactive({});

const searchPrj = () => {
  var params = {
    pageNo: prjPagination.current,
    pageSize: prjPagination.pageSize,
    queryParam: Object.assign({}, searchPrjModel),
  };
  prjLoading.value = true;
  projectApi.page(params).then((res) => {
    prjData.value = res.records;
    prjPagination.total = res.total;
    prjLoading.value = false;
  });
};

const standardLoading = ref(false);
const standardPagination = reactive({
  total: 0,
  current: 1,
  pageSize: 15,
  showPageSize: true,
  pageSizeOptions: [15, 25, 30, 50],
  showTotal: true,
  pageChange: (current) => {
    standardPagination.current = current;
    standardSearch();
  },
  pageSizeChange(size) {
    standardPagination.pageSize = size;
    standardSearch();
  },
});

const totalStandardLoading = ref(false);
const totalStandardPagination = reactive({
  total: 0,
  current: 1,
  pageSize: 15,
  showPageSize: true,
  pageSizeOptions: [15, 25, 30, 50],
  showTotal: true,
  pageChange: (current) => {
    totalStandardPagination.current = current;
    totalStandardSearch();
  },
  pageSizeChange(size) {
    totalStandardPagination.pageSize = size;
    totalStandardSearch();
  },
});

const totalStandardColumns = [
  {
    title: "分数",
    dataIndex: "score",
    width: 120
  },
  {
    title: "等级",
    dataIndex: "level",
    width: 120
  },
  {
    title: "折算后分数",
    dataIndex: "convertScore",
    width: 120
  },
  {
    title: "操作",
    slotName: "action",
    fixed: "right",
    width: 150,
  },
]

const standardColumns = [
  {
    title: "年级",
    dataIndex: "gradeName",
  },
  {
    title: "性别",
    slotName: "sex",
  },
  {
    title: "项目名称",
    dataIndex: "projectName",
    width: 150,
  },
  {
    title: "成绩",
    dataIndex: "testValue",
  },
  {
    title: "分数",
    dataIndex: "score",
  },
  {
    title: "等级",
    dataIndex: "level",
  },
  {
    title: "操作",
    slotName: "action",
    fixed: "right",
    width: 150,
  },
];
const standardData = ref([]);
const totalStandardData = ref([]);
const showAddStandardDialog = ref(false);
const showAddTotalStandardDialog = ref(false);
let submitStandardData = ref({});
let submitTotalStandardData = ref({});
const standardForm = ref();
const totalStandardForm = ref();

const showTotalStandardAdd = () => {
  showAddTotalStandardDialog.value = true;
  nextTick(() => {
    totalStandardForm.value.resetFields();
    submitTotalStandardData.value.templateId = currentTemplateId.value;
  });
};

const showStandardAdd = () => {
  showAddStandardDialog.value = true;
  nextTick(() => {
    standardForm.value.resetFields();
    submitStandardData.value.templateId = currentTemplateId.value;
  });
};

const standardEditRecord = (record) => {
  showAddStandardDialog.value = true;
  nextTick(() => {
    standardForm.value.resetFields();
    submitStandardData.value = Object.assign({}, record);
  });
};

const standardDeleteRecord = (record) => {
  projectApi
    .deleteStandard({
      id: record.id,
    })
    .then((res) => {
      search();
    });
};

const totalStandardEditRecord = (record) => {
  showAddTotalStandardDialog.value = true;
  nextTick(() => {
    totalStandardForm.value.resetFields();
    submitTotalStandardData.value = Object.assign({}, record);
  });
};

const totalStandardDeleteRecord = (record) => {
  scoreTemplateApi
    .deleteTotalStandard({
      id: record.id,
    })
    .then((res) => {
      totalStandardSearch();
    });
};

const standardSearchModel = reactive({});

const standardSearch = () => {
  var params = {
    pageNo: standardPagination.current,
    pageSize: standardPagination.pageSize,
    queryParam: Object.assign({}, standardSearchModel),
  };
  standardLoading.value = true;
  projectApi.standardPage(params).then((res) => {
    standardData.value = res.records;
    standardPagination.total = res.total;
    standardLoading.value = false;
  });
};

const totalStandardSearch = () => {
  var params = {
    pageNo: totalStandardPagination.current,
    pageSize: totalStandardPagination.pageSize,
    queryParam: Object.assign({}, totalStandardSearchModel),
  };
  totalStandardLoading.value = true;
  scoreTemplateApi.totalStandardPage(params).then((res) => {
    totalStandardData.value = res.records;
    totalStandardPagination.total = res.total;
    totalStandardLoading.value = false;
  });
}

const handleStandardSubmitSuccess = (values) => {
  values.templateId = currentTemplateId.value;
  projectApi.saveStandard(values).then((res) => {
    showAddStandardDialog.value = false;
    Message.success("保存成功");
    standardSearch();
  });
}

const handleTotalStandardSubmitSuccess = (values) => {
  values.templateId = currentTemplateId.value;
  scoreTemplateApi.saveTotalStandard(values).then((res) => {
    showAddTotalStandardDialog.value = false;
    Message.success("保存成功");
    totalStandardSearch();
  });
}

const changeManageTab = (key) => {
  if (key == 1) {
    searchPrj();
  } else if (key == 2) {
    standardSearch();
  } else {
    totalStandardSearch();
  }
}

const showCopy = (record) => {
  visible.value = true;
  nextTick(() => {
    submitForm.value.resetFields();
    submitData.value = Object.assign({}, record);
    submitData.value.id = "";
    submitData.value.copyId = record.id;
    submitData.value.name = record.name + "（副本）";
  });
}

const reset = () => {
  searchForm.value.resetFields();
};

const showImportPrjDialog = ref(false);
const showImportStandardDialog = ref(false);
const openImportPrjDialog = () => {
  showImportPrjDialog.value = true;
  uploadPrjData.value.templateId = currentTemplateId.value;
}

const openImportStandardDialog = () => {
  showImportStandardDialog.value = true;
  uploadPrjData.value.templateId = currentTemplateId.value;
}

search();
queryRoleList();
querySchoolList();
</script>

<template>
  <div class="main-con">
    <a-card>
      <a-row>
        <a-col :flex="1">
          <a-form ref="searchForm" :model="searchModel" :label-col-props="{ span: 8 }" :wrapper-col-props="{ span: 16 }"
            label-align="left">
            <a-row :gutter="16">
              <a-col :span="8">
                <a-form-item field="name" label="模板名称">
                  <a-input v-model="searchModel.name" placeholder="请输入模板名称" />
                </a-form-item>
              </a-col>
              <a-col :span="8">
                <a-form-item>
                  <a-space :size="18">
                    <a-button type="primary" @click="refresh">
                      <template #icon>
                        <icon-search />
                      </template>
                      查询
                    </a-button>
                    <a-button @click="reset">
                      <template #icon>
                        <icon-refresh />
                      </template>
                      重置
                    </a-button>
                  </a-space>
                </a-form-item>
              </a-col>
            </a-row>
          </a-form>
        </a-col>
      </a-row>
    </a-card>
    <a-card style="margin-top: 20px">
      <div class="toolbar">
        <a-space>
          <a-button type="primary" @click="showAddDialog">
            <template #icon>
              <icon-plus />
            </template>
            新增评分模板
          </a-button>
        </a-space>
      </div>
      <a-table :columns="columns" row-key="id" :loading="loading" :data="data" @page-change="pagination.pageChange"
        @page-size-change="pagination.pageSizeChange" :pagination="pagination" :bordered="false">
        <template #type="{ record }">
          <a-tag>{{ record.type == 1 ? '公有' : '私有' }}</a-tag>
        </template>
        <template #action="{ record }">
          <a-space>
            <a-button type="primary" size="small" @click="editRecord(record)">编辑</a-button>
            <a-button size="small" @click="showManagerDialog(record)">管理</a-button>
            <a-button size="small" @click="showCopy(record)">复制</a-button>
            <a-popconfirm content="确认要删除该模板数据吗？" @ok="deleteRecord(record)">
              <a-button type="text" size="small">删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </a-table>
    </a-card>
    <a-modal v-model:visible="visible" title="新增/编辑评分模板" :footer="null">
      <a-form ref="submitForm" size="large" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }"
        :model="submitData" @submit-success="handleSubmitSuccess">
        <a-form-item field="name" label="模板名称" :rules="[{ required: true, message: '请输入模板名称' }]">
          <a-input v-model.trim="submitData.name" placeholder="请输入模板名称" />
        </a-form-item>
        <a-form-item field="type" label="类型" :rules="[{ required: true, message: '请选择类型' }]">
          <a-select v-model="submitData.type" placeholder="请选择类型">
            <a-option label="公有" value="1"></a-option>
            <a-option label="私有" value="2"></a-option>
          </a-select>
        </a-form-item>
        <a-form-item>
          <a-space>
            <a-button html-type="submit" type="primary">确认</a-button>
            <a-button @click="visible = false">取消</a-button>
          </a-space>
        </a-form-item>
      </a-form>
    </a-modal>

    <a-modal title="评分模板管理" width="80%" v-model:visible="showTempDialog" :footer="null">
      <div style="height: 750px;">

        <a-tabs position="left" style="height: 100%;" @change="changeManageTab">
          <a-tab-pane key="1" title="项目管理">
            <a-form ref="prjSearchForm" :model="searchPrjModel" :label-col-props="{ span: 6 }"
              :wrapper-col-props="{ span: 18 }" label-align="left" layout="inline">

              <a-form-item field="projectName" label="项目名称">
                <a-input v-model="searchPrjModel.projectName" placeholder="请输入项目名称"></a-input>
              </a-form-item>
              <a-form-item field="gradeId" label="年级">
                <a-select style="width: 120px;" v-model="searchPrjModel.gradeId" placeholder="请选择年级">
                  <a-option v-for="item in constants.gradeList" :key="item.value" :value="item.value"
                    :label="item.label"></a-option>
                </a-select>
              </a-form-item>
              <a-form-item>
                <a-space>
                  <a-button type="primary" @click="searchPrj">查询</a-button>
                  <a-button @click="prjSearchForm.resetFields()">重置</a-button>
                </a-space>
                <a-divider direction="vertical" />
                <a-space>
                  <a-button type="outline" @click="showAddPrj">
                    <template #icon><icon-plus /></template>
                    新增项目
                  </a-button>
                  <a-button type="outline" @click="openImportPrjDialog">
                    <template #icon><icon-import /></template>
                    导入项目
                  </a-button>
                </a-space>
              </a-form-item>
            </a-form>
            <a-table :columns="prjColumns" row-key="id" :scroll="{ x: 1000, y: 600 }" :loading="prjLoading"
              :data="prjData" @page-change="prjPagination.pageChange" @page-size-change="prjPagination.pageSizeChange"
              :pagination="prjPagination" :bordered="false">
              <template #action="{ record }">
                <a-space>
                  <a-button type="text" size="mini" @click="editPrjRecord(record)">编辑</a-button>
                  <a-popconfirm content="确认要删除该数据吗？" @ok="deletePrjRecord(record)">
                    <a-button type="text" size="mini">删除</a-button>
                  </a-popconfirm>
                </a-space>
              </template>
            </a-table>
          </a-tab-pane>
          <a-tab-pane key="2" title="评分标准">
            <a-form ref="standardSearchForm" :model="standardSearchModel" layout="inline">
              <a-form-item field="projectName" label="项目名称">
                <a-input v-model="standardSearchModel.projectName" placeholder="请输入项目名称"></a-input>
              </a-form-item>
              <a-form-item field="sex" label="性别">
                <a-select style="width: 120px;" v-model="standardSearchModel.sex" placeholder="请选择性别">
                  <a-option :value="'1'">男</a-option>
                  <a-option :value="'2'">女</a-option>
                </a-select>
              </a-form-item>
              <a-form-item field="gradeId" label="年级">
                <a-select style="width: 120px;" v-model="standardSearchModel.gradeId" placeholder="请选择年级">
                  <a-option v-for="item in constants.gradeList" :key="item.value" :value="item.value"
                    :label="item.label"></a-option>
                </a-select>
              </a-form-item>
              <a-form-item>
                <a-space>
                  <a-button type="primary" @click="standardSearch">查询</a-button>
                  <a-button @click="standardSearchForm.resetFields()">重置</a-button>
                  <a-button type="outline" @click="showStandardAdd">
                    <template #icon><icon-plus /></template>
                    新增标准
                  </a-button>
                  <a-button type="outline" @click="openImportStandardDialog">
                    <template #icon><icon-import /></template>
                    导入标准
                  </a-button>
                </a-space>
              </a-form-item>
            </a-form>
            <a-table :columns="standardColumns" row-key="id" :scroll="{ x: 1000, y: 600 }" :loading="standardLoading"
              :data="standardData" @page-change="standardPagination.pageChange"
              @page-size-change="standardPagination.pageSizeChange" :pagination="standardPagination" :bordered="false">
              <template #sex="{ record }">
                {{ record.sex == "1" ? "男" : " 女" }}
              </template>
              <template #action="{ record }">
                <a-space>
                  <a-button type="text" size="mini" @click="standardEditRecord(record)">编辑</a-button>
                  <a-popconfirm content="确认要删除该数据吗？" @ok="standardDeleteRecord(record)">
                    <a-button type="text" size="mini">删除</a-button>
                  </a-popconfirm>
                </a-space>
              </template>
            </a-table>
          </a-tab-pane>
          <a-tab-pane key="3" title="总分等级">
            <div class="toolbar">
              <a-space>
                <a-button type="outline" @click="showTotalStandardAdd">
                  <template #icon><icon-plus /></template>
                  新增总分等级
                </a-button>
              </a-space>
            </div>
            <a-table :columns="totalStandardColumns" row-key="id" :scroll="{ x: 1000, y: 600 }"
              :loading="totalStandardLoading" :data="totalStandardData"
              @page-change="totalStandardPagination.pageChange"
              @page-size-change="totalStandardPagination.pageSizeChange" :pagination="totalStandardPagination"
              :bordered="false">
              <template #action="{ record }">
                <a-space>
                  <a-button type="text" size="mini" @click="totalStandardEditRecord(record)">编辑</a-button>
                  <a-popconfirm content="确认要删除该数据吗？" @ok="totalStandardDeleteRecord(record)">
                    <a-button type="text" size="mini">删除</a-button>
                  </a-popconfirm>
                </a-space>
              </template>
            </a-table>
          </a-tab-pane>
        </a-tabs>
      </div>

    </a-modal>
    <a-modal title="新增/编辑项目" width="800px" v-model:visible="showAddPrjDialog" :footer="null">
      <a-form ref="prjForm" :model="prjModel" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }"
        @submit-success="handleProjectSubmitSuccess">
        <a-row :gutter="10">
          <a-col :span="12">
            <a-form-item field="projectName" label="项目名称" :rules="[{ required: true, message: '请输入项目名称' }]">
              <a-input v-model="prjModel.projectName" placeholder="请输入项目名称"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="prjUnit" label="单位">
              <a-input v-model="prjModel.prjUnit" placeholder="请输入项目测试单位（如毫升）"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="minValue" label="最小值">
              <a-input-number :precision="2" mode="button" v-model="prjModel.minValue"
                placeholder="请输入最小值"></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="maxValue" label="最大值">
              <a-input-number :precision="2" mode="button" v-model="prjModel.maxValue"
                placeholder="请输入最大值"></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="radixLength" label="小数点进位">
              <a-input-number :precision="2" mode="button" v-model="prjModel.radixLength"
                placeholder="请输入小数点进位"></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="radixType" label="进位类型">
              <a-input :precision="2" mode="button" v-model="prjModel.radixType" placeholder="请输入进位类型（不取舍）"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="gradeId" label="所属年级" :rules="[{ required: true, message: '请选择年级' }]">
              <a-select v-model="prjModel.gradeId" placeholder="请选择年级">
                <a-option v-for="grade in constants.gradeList" :key="grade.value" :label="grade.label"
                  :value="grade.value"></a-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="prjWeight" label="项目权重" :rules="[{ required: true, message: '请输入项目权重' }]">
              <a-input-number :precision="4" mode="button" v-model="prjModel.prjWeight"
                placeholder="请输入项目权重"></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="prjType" label="项目类型">
              <a-input mode="button" v-model="prjModel.prjType" placeholder="请输入项目类型（计时，计数）"></a-input>
            </a-form-item>
          </a-col>
        </a-row>
        <div style="text-align: center;">
          <a-space>
            <a-button type="primary" html-type="submit">保存</a-button>
            <a-button @click="showAddPrjDialog = false">取消</a-button>
          </a-space>
        </div>
      </a-form>
    </a-modal>

    <a-modal title="新增/编辑总分等级" width="500px" v-model:visible="showAddTotalStandardDialog" :footer="null">
      <a-form ref="totalStandardForm" :model="submitTotalStandardData"
        @submit-success="handleTotalStandardSubmitSuccess">
        <a-row :gutter="10">
          <a-col :span="24">
            <a-form-item field="score" label="得分" :rules="[{ required: true, message: '请输入得分' }]">
              <a-input-number :precision="2" mode="button" v-model="submitTotalStandardData.score"
                placeholder="请输入得分"></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :span="24">
            <a-form-item field="level" label="等级" :rules="[{ required: true, message: '请输入等级' }]">
              <a-input v-model="submitTotalStandardData.level" placeholder="请输入等级"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="24">
            <a-form-item field="convertScore" label="折算分">
              <a-input-number :precision="2" mode="button" v-model="submitTotalStandardData.convertScore"
                placeholder="请输入折算后分数"></a-input-number>
            </a-form-item>
          </a-col>
        </a-row>
        <div style="text-align: center;">
          <a-space>
            <a-button type="primary" html-type="submit">保存</a-button>
            <a-button @click="showAddTotalStandardDialog = false">取消</a-button>
          </a-space>
        </div>
      </a-form>
    </a-modal>

    <a-modal title="新增/编辑评分标准" width="800px" v-model:visible="showAddStandardDialog" :footer="null">
      <a-form ref="standardForm" :model="submitStandardData" :label-col-props="{ span: 6 }"
        :wrapper-col-props="{ span: 18 }" @submit-success="handleStandardSubmitSuccess">
        <a-row :gutter="10">
          <a-col :span="12">
            <a-form-item field="gradeId" label="年级" :rules="[{ required: true, message: '请选择年级' }]">
              <a-select v-model="submitStandardData.gradeId" placeholder="请选择年级">
                <a-option v-for="grade in constants.gradeList" :key="grade.value" :label="grade.label"
                  :value="grade.value"></a-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="sex" label="性别" :rules="[{ required: true, message: '请选择性别' }]">
              <a-select v-model="submitStandardData.sex" placeholder="请选择性别">
                <a-option value="1">男</a-option>
                <a-option value="2">女</a-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="projectName" label="项目名称" :rules="[{ required: true, message: '请输入项目名称' }]">
              <a-input v-model="submitStandardData.projectName" placeholder="请输入项目名称"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="testValue" label="成绩" :rules="[{ required: true, message: '请输入成绩' }]">
              <a-input v-model="submitStandardData.testValue" placeholder="请输入成绩"></a-input>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="score" label="得分">
              <a-input-number :precision="2" mode="button" v-model="submitStandardData.score"
                placeholder="请输入得分"></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :span="12">
            <a-form-item field="level" label="等级">
              <a-input v-model="submitStandardData.level" placeholder="请输入等级"></a-input>
            </a-form-item>
          </a-col>
        </a-row>
        <div style="text-align: center;">
          <a-space>
            <a-button type="primary" html-type="submit">保存</a-button>
            <a-button @click="showAddStandardDialog = false">取消</a-button>
          </a-space>
        </div>
      </a-form>
    </a-modal>
    <a-modal v-model:visible="showImportPrjDialog" width="600px" :hide-cancel="true" :draggable="true" @ok="searchPrj"
      title="导入体测项目">
      <a-space direction="vertical" style="width: 100%; text-align: center">
        <div style="color: #999">
          暂时只支持符合导入模板要求的文件进行上传，请按需下载导入模板，编辑后再上传
        </div>
        <a-button type="link" href="/体测项目模板.xlsx" style="margin-bottom: 10px">体测项目导入模板下载</a-button>
        <Upload :uploadData="uploadPrjData" accept=".xls,.xlsx" :draggable="true" action="/admin/v1/project/import" />
      </a-space>
    </a-modal>

    <a-modal v-model:visible="showImportStandardDialog" width="600px" :hide-cancel="true" :draggable="true"
      @ok="standardSearch" title="导入评分标准">
      <a-space direction="vertical" style="width: 100%; text-align: center">
        <div style="color: #999">
          暂时只支持符合导入模板要求的文件进行上传，请按需下载导入模板，编辑后再上传
        </div>
        <a-button type="link" href="/评分标准模板.xlsx" style="margin-bottom: 10px">评分标准模板下载</a-button>
        <Upload :uploadData="uploadPrjData" accept=".xls,.xlsx" :draggable="true"
          action="/admin/v1/project/importStandard" />
      </a-space>
    </a-modal>
  </div>
</template>

<style scoped></style>
